package com.hank.vo;


/**
 * @author gaoZhiHao
 * @date 2023/5/11 11:49
 */

public class Result<T> {


    private String version = "v1";


    private Boolean status;


    private Integer code;


    private String message;


    private T data;

    public Result() {
        this.status = true;
        this.code = 200;
        this.message = "成功";
        this.data = null;
    }

    public Result(Boolean status, Integer code, String message, T data) {
        this.status = status;
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public Result(T data) {
        this.status = true;
        this.code = 200;
        this.message = "成功";
        this.data = data;
    }
    public Result(String data) {
        this.status = true;
        this.code = 500;
        this.message = data;
    }

    public static <T> Result<T> ok() {
        return new Result<>();
    }

    public static <T> Result<T> ok(T data) {
        return new Result<>(data);
    }


    public static <T> Result<T> error() {
        return error(false, 400, "失败");
    }
    public static <T> Result<T> error(String message) {
        return error(false, 400, message);
    }


    public static <T> Result<T> error(Boolean status, Integer code, String message) {
        return new Result<T>(status, code, message, null);
    }

    public static Result<Object> success(String token) {
        return new Result<>();
    }

    public static Result<Object> failure(String s) {
        return new Result<>(s);
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public Boolean getStatus() {
        return status;
    }

    public void setStatus(Boolean status) {
        this.status = status;
    }
}
